from sklearn.linear_model import LogisticRegression
# 导入数据集
from sklearn.datasets import  load_iris

# 导入分隔数据集方法
from sklearn.model_selection import train_test_split

iris_dataset = load_iris()

print("data 数组类型：{}".format(type(iris_dataset['data'])))

print("前五朵花数据：\n {}".format(iris_dataset['data'][:5]))


X_train,X_test,Y_train,Y_test=train_test_split(iris_dataset['data'], iris_dataset['target'], random_state=0)

# 设置最大迭代次数3000，默认1000，不更改会警告提示
log_reg = LogisticRegression(max_iter=3000)

clm = log_reg.fit(X_train, Y_train)

print(clm.predict(X_test))
print(clm.score(X_test, Y_test))